package com.sxy.mapper;

import com.sxy.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author 宋鑫宇
 * @version 1.0
 */
public interface UserMapper {
    /**
     * 登录：验证账号密码是否存在
     */
    @Select("select * from tb_user where username = #{username} and password = #{password} ")
    User select(@Param("username") String username, @Param("password") String password);

    /**
     * 注册：首先验证用户名是否存在，存在则不能创建
     * 其次再进行执行添加sql
     */
    @Select("select * from tb_user where username = #{username}")
    User selectByUsername(String username);

    @Insert("insert into tb_user(username,password) values (#{username},#{password})")
    void add(@Param("username") String username, @Param("password") String password);
}
